/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package WS;

import BD.Modulos.BdLugares;
import Interfaces.BdException;
import Objects.City;
import Objects.Country;
import Objects.Municipality;
import Objects.Parish;
import Objects.State;
import Tools.Tools;
import java.sql.SQLException;
import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.WebServiceContext;
/**
 *
 * @author ARMGARCES
 */
@WebService(serviceName = "Lugares")
public class Lugares {
    @Resource
    WebServiceContext wsContext;     
    /***************************************************************************/
    /******************************** COUNTRY **********************************/
    /***************************************************************************/    
    /**
     * Web service operation which looks up for all countries registered
     * @return Array of Countries
     * @throws Interfaces.BdException
     */
    @WebMethod(operationName = "loadCountry")
    public synchronized Country[] loadCountry() throws BdException {
        try{
            return (Country[]) BdLugares.getInstance().load(new Country());      
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    } 
    /***************************************************************************/
    /********************************* STATE ***********************************/
    /***************************************************************************/
    /**
     * Web service operation which looks up for all states registered
     * @return Array of States
     * @throws Interfaces.BdException
     */
    @WebMethod(operationName = "loadState")
    public synchronized State[] loadState() throws BdException {
        try{
            return (State[]) BdLugares.getInstance().load(new State());      
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    }       
    /**
     * Web service operation which look up for any states on a desired Country
     * @param find name value of a Country
     * @return Array of Country's State
     * @throws Interfaces.BdException
     */
    @WebMethod(operationName = "findState")
    public synchronized State[] findState(@WebParam(name = "find")String find) throws BdException {
        try{
            return (State[]) BdLugares.getInstance().find(new State(),find,null);      
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    }  
    /***************************************************************************/
    /********************************** CITY ***********************************/
    /***************************************************************************/
    /**
     * Web service operation which looks up for all cities registered
     * @return Array of Cities
     * @throws Interfaces.BdException
     */
    @WebMethod(operationName = "loadCity")
    public synchronized City[] loadCity() throws BdException{
        try{
            return (City[]) BdLugares.getInstance().load(new City());      
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    }    
    /**
     * Web service operation which look up for any cities on a desired State
     * @param find name value of State
     * @return Array of State's Cities
     * @throws Interfaces.BdException
     */
    @WebMethod(operationName = "findCity")
    public synchronized City[] findCity(@WebParam(name = "find") String find) throws BdException{
        //TODO write your implementation code here:
        try{
            return (City[]) BdLugares.getInstance().find(new City(),find,null);              
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    }    
    /***************************************************************************/
    /****************************** MUNICIPALITY *******************************/
    /***************************************************************************/    
    /**
     * Web service operation which looks up for all municipalities registered
     * @return Array of Cities
     * @throws Interfaces.BdException
     */
    @WebMethod(operationName = "loadMunicipality")
    public synchronized Municipality[] loadMunicipality() throws BdException {
        try{
            return (Municipality[]) BdLugares.getInstance().load(new Municipality());      
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    }    
    /**
     * Web service operation which look up for 
     * @param find name value of 
     * @return Array of State's Cities
     * @throws Interfaces.BdException
     */
    @WebMethod(operationName = "findMunicipality")
    public synchronized Municipality[] findMunicipality(@WebParam(name = "find")String find) throws BdException {
        try{
            return (Municipality[]) BdLugares.getInstance().find(new Municipality(),find,null);      
            }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    }    
    /***************************************************************************/
    /********************************* PARISH **********************************/
    /***************************************************************************/    
    /**
     * Web service operation which looks up for all parish registered
     * @return Array of 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "loadParish")
    public synchronized Parish[] loadParish() throws BdException {
        try{
            return (Parish[]) BdLugares.getInstance().load(new Parish());      
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    }    
    /**
     * Web service operation which look up for 
     * @param findM 
     * @param findS 
     * @return Array of 
     * @throws Interfaces.BdException 
     */
    @WebMethod(operationName = "findParish")
    public synchronized Parish[] findParish(@WebParam(name = "findM") String findM,
                                             @WebParam(name = "findS") String findS) throws BdException {
        try{
            return (Parish[]) BdLugares.getInstance().find(new Parish(),findM, findS);               
        }catch(BdException bde){
            throw bde;
        } catch (SQLException ex) {
        }
        return null;
    }         
}
